-
Notifications
You must be signed in to change notification settings - Fork 4
[NAE-2072] Workspaces #280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/7.0.0-rev2
Are you sure you want to change the base?
Conversation
- add changing workspaces to doubledrawer menu
# Conflicts: # projects/netgrif-components-core/src/lib/user/models/iuser.ts # projects/netgrif-components-core/src/lib/user/services/user.service.ts # projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication-method-service.ts # projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts # projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-user-resource.service.ts
- change funcionality
WalkthroughThe changes introduce workspace support across user, case, task, and process models, services, and UI components. New properties and interfaces for workspace identification are added, along with methods to retrieve and switch workspaces. The navigation drawer UI now includes a menu for workspace selection, and observables are set up to manage and display available workspaces to the user. Changes
Sequence Diagram(s)sequenceDiagram
participant User as User
participant NavDrawer as NavigationDoubleDrawerComponent
participant UserService as UserService
participant UserResource as UserResourceService
User->>NavDrawer: Clicks workspace menu button
NavDrawer->>UserService: get workspaces$
UserService->>UserResource: getAllWorkspaces()
UserResource-->>UserService: Array<Workspace>
UserService-->>NavDrawer: workspaces$ observable emits workspaces
User->>NavDrawer: Selects a workspace
NavDrawer->>UserService: setWorkspace(workspaceId)
UserService->>UserResource: changeWorkspace(workspaceId)
UserResource-->>UserService: Updated UserResource
UserService->>User: Reloads window to apply workspace change
sequenceDiagram
participant UserService
participant UserResource
participant App
UserService->>UserResource: getLoggedUser()
UserResource-->>UserService: UserResource (with workspaceId)
UserService->>UserService: transform UserResource to User (with workspaceId)
UserService->>UserService: loadWorkspaces()
UserService->>UserResource: getAllWorkspaces()
UserResource-->>UserService: Array<Workspace>
UserService-->>App: Emits user and workspaces observables
Suggested labels
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (5)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
- add workspaceId to some objects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
🔭 Outside diff range comments (1)
projects/netgrif-components-core/src/lib/user/services/user.service.ts (1)
86-91
:⚠️ Potential issueAdd cleanup for the workspaces subject to prevent memory leaks.
The
_workspaces
ReplaySubject should be completed inngOnDestroy
:ngOnDestroy(): void { this._userChange$.complete(); this._anonymousUserChange$.complete(); + this._workspaces.complete(); this._subAuth.unsubscribe(); this._subAnonym.unsubscribe(); }
🧹 Nitpick comments (4)
projects/nae-example-app/src/app/doc/sidemenu-example/sidemenu-example.component.ts (1)
44-44
: Consider using a more meaningful default value for workspaceId.Using empty strings (
''
) as default values forworkspaceId
may not clearly indicate whether a workspace is actually assigned. Consider using:
null
orundefined
for unassigned workspaces- A default workspace identifier (e.g.,
'default'
)- A constant for the default workspace value
Example improvement:
- workspaceId: '' + workspaceId: null // or 'default-workspace'This makes the intent clearer and allows for better validation logic.
Also applies to: 57-57
projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-user-resource.service.ts (1)
24-24
: Mock service updated consistently with interface changes.The addition of
workspaceId: ''
to the mockUserResource
maintains consistency with the workspace feature implementation.Consider whether the empty string default is appropriate for all test scenarios. Some tests might benefit from having a mock workspace ID to verify workspace-specific behavior:
-workspaceId: '', +workspaceId: 'test-workspace-id',projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-net.ts (1)
34-34
: Consider standardizing mock default values across utilities.The workspace ID additions are correct, but there's an inconsistency in default values: this utility uses empty strings while
create-mock-task.ts
uses'string'
. Consider standardizing these values for consistent test behavior.Standardize the default value pattern:
- workspaceId: '', + workspaceId: 'string',- workspaceId: '', + workspaceId: 'string',Also applies to: 47-47
projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts (1)
85-95
: Fix JSDoc comment inconsistency.The JSDoc comment incorrectly states this is a GET request, but the implementation uses POST which is appropriate for changing workspace state.
/** - * Get all workspaces + * Change active workspace * - * **Request Type:** GET + * **Request Type:** POST * - * **Request URL:** {{baseUrl}}/api/user/workspaces + * **Request URL:** {{baseUrl}}/api/user/workspace */
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (22)
projects/nae-example-app/src/app/doc/panels/panels.component.ts
(2 hunks)projects/nae-example-app/src/app/doc/sidemenu-example/sidemenu-example.component.ts
(2 hunks)projects/netgrif-components-core/src/lib/authentication/models/user.transformer.ts
(1 hunks)projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts
(5 hunks)projects/netgrif-components-core/src/lib/process/net.ts
(3 hunks)projects/netgrif-components-core/src/lib/process/process.service.ts
(1 hunks)projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts
(2 hunks)projects/netgrif-components-core/src/lib/resources/interface/case.ts
(1 hunks)projects/netgrif-components-core/src/lib/resources/interface/petri-net-reference.ts
(1 hunks)projects/netgrif-components-core/src/lib/resources/interface/task.ts
(1 hunks)projects/netgrif-components-core/src/lib/user/models/iuser.ts
(1 hunks)projects/netgrif-components-core/src/lib/user/models/user.ts
(1 hunks)projects/netgrif-components-core/src/lib/user/models/workspace.ts
(1 hunks)projects/netgrif-components-core/src/lib/user/services/user.service.ts
(8 hunks)projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication-method-service.ts
(1 hunks)projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts
(1 hunks)projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-user-resource.service.ts
(1 hunks)projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-case.ts
(1 hunks)projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-net.ts
(2 hunks)projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task.ts
(1 hunks)projects/netgrif-components/src/lib/navigation/navigation-double-drawer/navigation-double-drawer.component.html
(1 hunks)projects/netgrif-components/src/lib/navigation/navigation.theme.scss
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts (1)
projects/netgrif-components-core/src/lib/user/models/user.ts (1)
User
(7-64)
projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts (2)
projects/netgrif-components-core/src/lib/resources/resource-provider.service.ts (1)
Params
(12-12)projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)
Workspace
(2-5)
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts (1)
projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)
Workspace
(2-5)
projects/netgrif-components-core/src/lib/user/services/user.service.ts (3)
projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)
Workspace
(2-5)projects/netgrif-components-core/src/lib/user/models/user.ts (1)
User
(7-64)projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts (1)
user
(310-312)
⏰ Context from checks skipped due to timeout of 90000ms (5)
- GitHub Check: task-list-completed
- GitHub Check: Matrix Test (20)
- GitHub Check: Matrix Test (18)
- GitHub Check: Test with SonarCloud
- GitHub Check: task-list-completed
🔇 Additional comments (24)
projects/netgrif-components/src/lib/navigation/navigation.theme.scss (1)
22-24
: LGTM! Clean and consistent styling addition.The new
.menu-button-selected
class follows the established pattern of using the primary palette color for selected states, consistent with other similar classes in the theme.projects/netgrif-components-core/src/lib/user/models/workspace.ts (1)
2-5
: Well-designed interface for workspace representation.The
Workspace
interface is clean and appropriately minimal, with clear property names and types that align with the workspace functionality requirements.projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task.ts (1)
21-21
: Mock utility properly updated for workspace support.The addition of
workspaceId
maintains consistency with other mock properties and supports testing of workspace-aware functionality.projects/netgrif-components-core/src/lib/process/process.service.ts (1)
272-272
: LGTM: Improved null safety with optional chaining.The change from
!reference.stringId
to!reference?.stringId
provides better null safety by preventing potential runtime errors whenreference
is null or undefined. This defensive programming approach is especially valuable when handling external data sources.projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication.service.ts (1)
22-22
: LGTM: Correctly updated User constructor for workspace support.The change properly aligns with the new User constructor signature by adding an empty string for
workspaceId
as the 7th parameter, with['ADMIN']
correctly positioned as the 8th parameter for authorities. This maintains the mock's functionality while supporting the workspace feature.projects/netgrif-components-core/src/lib/authentication/models/user.transformer.ts (1)
26-26
: LGTM: Properly implements workspaceId transformation.The addition of
user.workspaceId
correctly extracts the workspace information from theUserResource
and passes it to theUser
constructor in the correct position. This ensures workspace data is properly mapped from the backend resource to the domain model.projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-case.ts (1)
38-39
: LGTM: Adds workspace support to mock case utility.The addition of
workspaceId: ''
properly extends the mock Case object to support the workspace feature. Using an empty string as the default value is appropriate for testing scenarios and maintains consistency with other workspace-related mock utilities.projects/netgrif-components-core/src/lib/process/net.ts (2)
26-29
: LGTM - Consistent property declaration.The workspaceId property follows the established pattern in the Net class with proper JSDoc documentation.
207-213
: LGTM - Consistent getter and setter implementation.The getter and setter methods follow the established pattern used by other properties in the Net class.
projects/netgrif-components/src/lib/navigation/navigation-double-drawer/navigation-double-drawer.component.html (2)
117-122
: LGTM - Well-structured workspace menu.The mat-menu implementation correctly uses Angular directives with proper async pipe handling, conditional styling, and workspace identification logic. The menu positioning and trigger configuration are appropriate.
124-130
: LGTM - Properly implemented workspace selector button.The button correctly uses structural directive for conditional display, proper Material Design button styling, tooltip integration, and menu triggering. The translation key usage follows the established pattern.
projects/netgrif-components-core/src/lib/resources/engine-endpoint/user-resource.service.ts (2)
13-13
: LGTM - Proper import of Workspace interface.The import statement correctly references the Workspace interface from the user models directory.
73-83
: LGTM - Well-implemented getAllWorkspaces method.The method follows the established service pattern with proper JSDoc documentation, correct HTTP method usage, and consistent return type handling.
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts (4)
6-7
: LGTM - Proper RxJS and interface imports.The import statements correctly add the necessary RxJS operators and Workspace interface for the new functionality.
121-122
: LGTM - Well-defined workspace properties.The properties are properly typed and follow the established naming conventions in the component.
171-173
: LGTM - Proper workspace observable initialization.The workspace observable setup correctly uses the tap operator to maintain the workspace count and follows Angular best practices for observable handling in ngOnInit.
239-245
: LGTM - Clean workspace management methods.Both methods are well-implemented with clear responsibilities: setWorkspace delegates to the UserService for state management, and activeWorkspace provides direct access to the current workspace ID.
projects/netgrif-components-core/src/lib/user/services/user.service.ts (7)
2-2
: LGTM!The import additions are necessary for the new workspace functionality and follow the existing patterns.
Also applies to: 15-15
29-29
: LGTM!The workspace property follows the established pattern used for user observables in this service.
Also applies to: 42-42
48-49
: LGTM!The conditional logic properly handles workspace loading for different authentication scenarios.
74-76
: LGTM!The workspaces observable getter follows the established pattern used by other observables in this service.
189-189
: LGTM!The correction properly includes the
workspaceId
parameter to match the updated User constructor.
198-198
: LGTM!Loading workspaces after successfully loading the user is logical and follows the expected sequence of operations.
223-231
: LGTM!The method follows the established pattern for loading data from the user resource service, with appropriate error logging.
/** | ||
* **Example:** default | ||
*/ | ||
workspaceId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
LGTM! Consistent interface extension.
The workspaceId
property follows the established documentation pattern and type conventions. The "default" example value suggests proper fallback handling.
Consider whether validation should be added for workspace ID format and if this should be optional for backward compatibility:
🏁 Script executed:
#!/bin/bash
# Check if there are any existing usages of IUser that might break with this required property
rg -A 3 -B 3 "implements IUser|extends IUser|: IUser"
Length of output: 69072
Add workspaceId
to all IUser
implementations
The new required workspaceId: string
on IUser
is a breaking change for existing classes and interfaces that implement or extend IUser
. You need to update them accordingly:
• In projects/netgrif-components-core/src/lib/user/models/user.ts
– Add a public workspaceId: string
parameter to the User
constructor (or make it optional with a default)
– Assign it to the class field so instances implement the new interface member
• In projects/netgrif-components-core/src/lib/resources/interface/user-resource-small.ts
– Add workspaceId: string;
(or workspaceId?: string;
for backward compatibility) to UserResourceSmall
Also update any mapping or factory methods that create User
or UserResourceSmall
to populate workspaceId
.
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/user/models/iuser.ts around lines 37
to 40, adding the required workspaceId property to the IUser interface is a
breaking change. To fix this, update all IUser implementations accordingly: in
projects/netgrif-components-core/src/lib/user/models/user.ts, add a public
workspaceId string parameter to the User constructor (optionally with a default
value) and assign it to the class field; in
projects/netgrif-components-core/src/lib/resources/interface/user-resource-small.ts,
add workspaceId as a string property (optionally make it optional for backward
compatibility). Also, update any factory or mapping methods that create User or
UserResourceSmall instances to ensure workspaceId is properly populated.
return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: '', | ||
groups: [], authorities: [], nextGroups: [], processRoles: []}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Inconsistent workspace ID value in mock data.
The mock uses an empty string for workspaceId
, but the IUser
interface example suggests "default" as the expected value. This inconsistency could lead to test scenarios that don't match real-world usage.
Consider updating the mock to use a consistent default value:
- return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: '',
+ return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: 'default',
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
return of({email: 'mail', id: 'id', username: 'username', realmId: 'realmId', name: 'name', firstName: 'name', surname: 'surname', lastName: 'surname', fullName: 'name surname', workspaceId: '', | |
groups: [], authorities: [], nextGroups: [], processRoles: []}); | |
return of({ | |
email: 'mail', | |
id: 'id', | |
username: 'username', | |
realmId: 'realmId', | |
name: 'name', | |
firstName: 'name', | |
surname: 'surname', | |
lastName: 'surname', | |
fullName: 'name surname', | |
workspaceId: 'default', | |
groups: [], | |
authorities: [], | |
nextGroups: [], | |
processRoles: [] | |
}); |
🤖 Prompt for AI Agents
In
projects/netgrif-components-core/src/lib/utility/tests/mocks/mock-authentication-method-service.ts
at lines 8-9, the mock user object sets workspaceId to an empty string, which is
inconsistent with the IUser interface example that uses "default". Update the
workspaceId value in the mock to "default" to ensure test data aligns with
expected real-world values and avoid potential test discrepancies.
@@ -83,7 +84,8 @@ export class PanelsComponent implements OnInit { | |||
email: 'test@netgrif.com', | |||
fullName: 'Test Testovič' | |||
}, | |||
immediateData: [] | |||
immediateData: [], | |||
workspaceId: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use consistent default workspace ID value.
Similar to the case object above, consider using "default" instead of an empty string for consistency.
- workspaceId: ''
+ workspaceId: 'default'
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
workspaceId: '' | |
workspaceId: 'default' |
🤖 Prompt for AI Agents
In projects/nae-example-app/src/app/doc/panels/panels.component.ts at line 88,
the default value for workspaceId is set as an empty string, which is
inconsistent with the "case" object that uses "default". Change the default
value of workspaceId from an empty string to "default" to maintain consistency
across the code.
@@ -68,7 +68,8 @@ | |||
stringId: null, | |||
petriNetId: null, | |||
permissions: {}, | |||
users: {} | |||
users: {}, | |||
workspaceId: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Use consistent default workspace ID value.
The empty string value for workspaceId
is inconsistent with the "default" example shown in the IUser
interface. For demo purposes, using a meaningful value would be better.
- workspaceId: ''
+ workspaceId: 'default'
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
workspaceId: '' | |
workspaceId: 'default' |
🤖 Prompt for AI Agents
In projects/nae-example-app/src/app/doc/panels/panels.component.ts at line 72,
the default value for workspaceId is set to an empty string, which is
inconsistent with the "default" example in the IUser interface. Update the
workspaceId default value to match the meaningful default value used in the
IUser interface to maintain consistency and improve demo clarity.
/** | ||
* Workspace id | ||
* */ | ||
workspaceId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Improve documentation consistency.
The workspaceId
property documentation lacks an example value, unlike other properties in this interface. Consider adding an example for consistency.
/**
- * Workspace id
+ * **Example:** default
+ *
+ * Workspace id
* */
Verify that existing code creating Case objects won't break with this new required property:
🏁 Script executed:
#!/bin/bash
# Check for Case object creation that might miss the new required property
rg -A 5 -B 2 "new.*Case|Case.*=" --type ts
Length of output: 66678
Add a usage example for workspaceId
(no breaking changes detected)
I didn’t find any object literals or new Case
constructions missing the new required workspaceId
field—most Case
instances flow through service calls or are returned from the backend, so TypeScript will receive the field at runtime. However, the documentation on the workspaceId
property should still be expanded to match the style of neighboring fields.
• File: projects/netgrif-components-core/src/lib/resources/interface/case.ts
• Lines: 114–117
Suggested diff:
/**
- * Workspace id
+ * **Example:** default
+ *
+ * Workspace id
*/
workspaceId: string;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
/** | |
* Workspace id | |
* */ | |
workspaceId: string; | |
/** | |
* **Example:** default | |
* | |
* Workspace id | |
*/ | |
workspaceId: string; |
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/resources/interface/case.ts around
lines 114 to 117, the workspaceId property lacks an example value in its
documentation, unlike other properties in the interface. Add an example value to
the JSDoc comment for workspaceId to maintain consistency in documentation style
without changing the code functionality.
/** | ||
* Workspace id | ||
* */ | ||
workspaceId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify all implementations are updated for the breaking change.
Adding the required workspaceId
property to the PetriNetReference
interface is a breaking change. Ensure all code that creates or implements this interface has been updated to include the new property.
Run the following script to verify all PetriNetReference
implementations include the new property:
🏁 Script executed:
#!/bin/bash
# Description: Find all PetriNetReference object creations and verify workspaceId is included
# Search for PetriNetReference object creations
rg -A 10 -B 2 "PetriNetReference|new.*Net\("
# Search for files that might be missing workspaceId in object literals
ast-grep --pattern $'{
$$$
title: $_,
$$$
}'
Length of output: 67189
Add workspaceId
to all PetriNetReference
instantiations
The new required workspaceId: string
field on PetriNetReference
is missing in several object literals and tests, causing type errors. Please update each literal to include workspaceId
(use an empty string ''
or appropriate value in tests). Key locations:
- projects/netgrif-components/src/lib/panel/workflow-panel/workflow-panel.component.spec.ts
- projects/netgrif-components/src/lib/panel/public-workflow-panel/public-workflow-panel.component.spec.ts
- projects/netgrif-components/src/lib/dialog/new-case-dialog/new-case-dialog.component.spec.ts
- projects/netgrif-components-core/src/lib/view/tree-case-view/tree-component/case-tree.service.spec.ts
- projects/netgrif-components-core/src/lib/process/net.spec.ts
Example update in a spec file:
public workflow: PetriNetReference = {
stringId: '',
title: '',
identifier: '',
version: '',
initials: '',
defaultCaseName: '',
createdDate: [],
author: { email: '', fullName: '' },
immediateData: undefined,
+ workspaceId: ''
};
Repeat for all other object literals where a PetriNetReference
is created.
🤖 Prompt for AI Agents
In
projects/netgrif-components-core/src/lib/resources/interface/petri-net-reference.ts
around lines 51 to 54, the PetriNetReference interface was updated to include a
new required property workspaceId of type string, which is a breaking change. To
fix this, update all object literals and tests that create or implement
PetriNetReference across the codebase to include the workspaceId property with
an appropriate value, such as an empty string '' in tests. Key files to update
include workflow-panel.component.spec.ts,
public-workflow-panel.component.spec.ts, new-case-dialog.component.spec.ts,
case-tree.service.spec.ts, and net.spec.ts. Ensure every PetriNetReference
instantiation has workspaceId added to avoid type errors.
/** | ||
* Workspace id | ||
* */ | ||
workspaceId: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify all Task implementations include the new required property.
The addition of the required workspaceId
property to the Task
interface is a breaking change. All code that creates Task
objects must be updated to include this property.
Run the following script to identify any Task object creations that might be missing the workspaceId:
🏁 Script executed:
#!/bin/bash
# Description: Find Task object creations and verify workspaceId inclusion
# Search for Task object creations and assignments
rg -A 15 "Task\s*=\s*{|:\s*Task\s*=|new.*Task\(|as\s+Task"
# Look for mock Task objects that might need updating
fd -e ts -x rg -l "Task.*mock|mock.*Task" {}
Length of output: 1368
🏁 Script executed:
#!/bin/bash
# 1. Find object literals explicitly annotated with Task:
echo "=== Object literals typed as Task ==="
rg -n -E ':\s*Task\s*=\s*\{' -n projects/netgrif-components-core || echo "No direct annotations found."
# 2. Find casts to Task:
echo -e "\n=== 'as Task' casts ==="
rg -n 'as\s\+Task' -n projects/netgrif-components-core || echo "No 'as Task' casts found."
# 3. Verify mocks include workspaceId:
echo -e "\n=== Checking mocks for workspaceId ==="
for f in $(fd -e ts -g "create-mock-task*.ts"); do
if rg -q "workspaceId" "$f"; then
echo "OK: workspaceId present in $f"
else
echo "MISSING: workspaceId not found in $f"
fi
done
Length of output: 1397
Include workspaceId
in all Task mocks
A required workspaceId
is missing from one of your test fixtures, which will break Task implementations in tests.
• projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task-outcome.ts
– Add a workspaceId: string
entry to the exported mock object.
Please also scan for any other untyped Task literals or fixtures to ensure they include the new workspaceId
property.
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/resources/interface/task.ts around
lines 73 to 76, the Task interface now requires a workspaceId string property,
which is a breaking change. You need to update all Task object creations,
especially test mocks like in
projects/netgrif-components-core/src/lib/utility/tests/utility/create-mock-task-outcome.ts,
to include a workspaceId string field. Review all Task literals, casts, and
mocks across the codebase to ensure they define workspaceId to prevent runtime
errors.
@@ -13,6 +13,7 @@ export class User implements IUser { | |||
public realmId: string, | |||
public firstName: string, | |||
public lastName: string, | |||
public workspaceId: string, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Verify constructor parameter placement doesn't break existing code.
Adding workspaceId
in the middle of the constructor parameters is a breaking change if any code instantiates User
objects using positional arguments rather than named parameters.
Run this script to verify all User constructor calls are compatible:
🏁 Script executed:
#!/bin/bash
# Description: Find all User constructor calls to verify they won't break with the new parameter
# Search for new User() instantiations
echo "=== Direct User constructor calls ==="
rg -A 3 "new User\(" --type ts
# Search for User constructor calls in factories or builders
echo -e "\n=== User creation in factories/transformers ==="
rg -A 5 "User\(" --type ts | grep -v "export class User"
# Check if UserTransformer or similar classes handle the new parameter
echo -e "\n=== UserTransformer implementations ==="
ast-grep --pattern 'class $_ {
$$$
transform($$$) {
$$$
new User($$$)
$$$
}
$$$
}'
Length of output: 65160
Fix User constructor parameter placement to avoid breaking changes.
The workspaceId
parameter was inserted mid‐constructor, but most new User(…)
calls across the repo (in transformers, services, mocks and specs) still use the old argument order. You must either:
- Move
workspaceId
to the end of the constructor signature in
projects/netgrif-components-core/src/lib/user/models/user.ts
, for example:constructor( public id: string, public username: string, public email: string, public realmId: string,
- public workspaceId: string,
public firstName: string,
public lastName: string,
/* … */
- public workspaceId: string,
) { }
- Or update every `new User(…)` invocation to supply the new fifth argument. Critical locations include:
• `authentication/models/user.transformer.ts`
• `user/services/user.service.ts` (emptyUser)
• `utility/tests/mocks/mock-authentication.service.ts`
• `view/case-view/abstract-case-view.spec.ts`
• …and dozens of other spec files under `projects/netgrif-components-core` and `projects/netgrif-components`
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
constructor(
public id: string,
public username: string,
public email: string,
public realmId: string,
public firstName: string,
public lastName: string,
public workspaceId: string,
/* … */
) { }
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/user/models/user.ts at line 16, the
workspaceId parameter was added in the middle of the User constructor
parameters, causing breaking changes for existing positional constructor calls.
To fix this, move the workspaceId parameter to the end of the constructor
parameter list to preserve the original argument order. Alternatively, update
all new User(...) calls across the codebase to include the new fifth argument in
the correct position, especially in critical files like
authentication/models/user.transformer.ts, user/services/user.service.ts,
utility/tests/mocks/mock-authentication.service.ts, and
view/case-view/abstract-case-view.spec.ts.
@@ -84,6 +88,7 @@ export class Net implements PetriNetReferenceWithPermissions { | |||
this._transactions = []; | |||
this._roles = []; | |||
this._uriNodeId = net.uriNodeId; | |||
this._workspaceId = net.workspaceId |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix missing semicolon.
The constructor initialization is missing a semicolon at the end of the line.
- this._workspaceId = net.workspaceId
+ this._workspaceId = net.workspaceId;
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
this._workspaceId = net.workspaceId | |
this._workspaceId = net.workspaceId; |
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/process/net.ts at line 91, the
assignment statement setting this._workspaceId is missing a semicolon at the
end. Add a semicolon to properly terminate the statement.
public changeWorkspace(workspaceId: string) { | ||
this._userResource.changeWorkspace(workspaceId).subscribe(user => { | ||
if (user) { | ||
window.location.reload(); | ||
} | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling and input validation.
The method should handle potential failures and validate the input parameter:
public changeWorkspace(workspaceId: string) {
+ if (!workspaceId) {
+ this._log.error('Workspace ID is required for workspace change');
+ return;
+ }
+
this._userResource.changeWorkspace(workspaceId).subscribe(user => {
if (user) {
window.location.reload();
}
+ }, error => {
+ this._log.error('Changing workspace has failed!', error);
});
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
public changeWorkspace(workspaceId: string) { | |
this._userResource.changeWorkspace(workspaceId).subscribe(user => { | |
if (user) { | |
window.location.reload(); | |
} | |
}); | |
} | |
public changeWorkspace(workspaceId: string) { | |
if (!workspaceId) { | |
this._log.error('Workspace ID is required for workspace change'); | |
return; | |
} | |
this._userResource.changeWorkspace(workspaceId).subscribe(user => { | |
if (user) { | |
window.location.reload(); | |
} | |
}, error => { | |
this._log.error('Changing workspace has failed!', error); | |
}); | |
} |
🤖 Prompt for AI Agents
In projects/netgrif-components-core/src/lib/user/services/user.service.ts around
lines 233 to 239, the changeWorkspace method lacks input validation and error
handling. Add a check to ensure workspaceId is valid before proceeding. Also,
add error handling in the subscription to manage potential failures from
changeWorkspace, such as logging the error or notifying the user, instead of
silently failing.
- add translations
Description
implements switch for workspaces
Implements NAE-2072
Dependencies
Third party dependencies
No new dependencies were introduced
Blocking Pull requests
There are no dependencies on other PR
How Has Been This Tested?
manually
Test Configuration
<Please describe configuration for tests to run if applicable, like program parameters, host OS, VM configuration etc. You can use >
Checklist:
Summary by CodeRabbit
New Features
Improvements
Style
Localization